#include"db.h"

int main()
{
    const char *create_table_sql = "create table if not exists users(id integer primary key autoincrement,name text not null,sex text not null,age integer check(age>=0 and age<=150));";
    const char *insert_into_sql = "insert into users(name,sex,age) values('zhangsan','f',23);";
    const char *insert_into_sql2 = "insert into users(name,sex,age) values('zhanggan','m',24);";
    int rc = sqlite3_open("test.db",&db);

    if(rc!=SQLITE_OK)
    {
        fprintf(stderr,"wufadakaishujuku:%s",sqlite3_errmsg(db));
        sqlite3_close(db);
    }
    rc =  sqlite3_exec(db,create_table_sql,NULL,0,NULL);
    
    rc =  sqlite3_exec(db,insert_into_sql,NULL,0,NULL);
    if(rc!=SQLITE_OK)
    {
        fprintf(stderr,"---------------------:%s",sqlite3_errmsg(db));
        sqlite3_close(db);
    }
   
    rc =  sqlite3_exec(db,insert_into_sql2,NULL,0,NULL);
    if(rc!=SQLITE_OK)
    {
        fprintf(stderr,"---------------------:%s",sqlite3_errmsg(db));
        sqlite3_close(db);
    }

    

    return 0;
}